package org.electric.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.electric.bean.CompanyExamineBean;
import org.electric.util.JDBCUtil;

/**
 * 企业审核Dao
 * 
 */
public class CompanyExamineDao {
	Connection conn = JDBCUtil.getConection();

	/**
	 * 查询遍历未审核企业名单
	 */
	public List<CompanyExamineBean> AllCompanyExamine_d() {
		List<CompanyExamineBean> list = new ArrayList<CompanyExamineBean>();
		StringBuffer sql = new StringBuffer();
		sql.append("SELECT * FROM company_info WHERE register_status = 0");
		PreparedStatement ent = null;
		ResultSet sr = null;
		try {
			ent = conn.prepareStatement(sql.toString());
			sr = ent.executeQuery();
			while (sr.next()) {
				CompanyExamineBean company = new CompanyExamineBean();
				company.setId(sr.getInt(1));
				company.setCompany_user(sr.getString(2));
				company.setCompany_name(sr.getString(4));
				company.setRegister_time(sr.getDate(5));
				company.setRegister_money(sr.getDouble(6));
				company.setEmployee_num(sr.getInt(7));
				company.setAddress(sr.getString(8));
				company.setLicense_id(sr.getString(9));
				company.setRegister_status(sr.getInt(10));
				company.setStatus(sr.getInt(11));
				company.setTel(sr.getString(12));
				list.add(company);
			}

		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		JDBCUtil.close(conn,ent,sr);
		return list;
	}

	/**
	 * 修改状态，审核通过
	 * 
	 *
	 */
	public int UpCompany_d(String license_id) {
		int count = 0;
		StringBuffer sql = new StringBuffer();
		sql.append("UPDATE company_info SET register_status = 1 WHERE license_id ='" + license_id + "'");
		PreparedStatement ment=null;
		try {
			ment = conn.prepareStatement(sql.toString());
			count = ment.executeUpdate();

		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		JDBCUtil.close(conn,ment);
		return count;
	}
	

}
